package com.hc.usb.impl;

import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.util.Log;

import java.nio.ByteBuffer;

public class USBCommandQuery extends USBCommandBase{
    public USBCommandQuery(int dCBWTag) {
        super(dCBWTag, 0x24, IN);
    }

    @Override
    public void serialize(ByteBuffer buffer) {
        super.serialize(buffer);
        buffer.put((byte)6)
                .put((byte)0x12)
                .put((byte) 0x00)
                .put((byte) 0x00)
                .put((byte) 0x00)
                .put((byte) 0x24)
                .put((byte) 0x00);
    }

    @Override
    public ByteBuffer data(UsbDeviceConnection usbDeviceConnection, UsbEndpoint usbEndpoint) {
        ByteBuffer buffer = super.data(usbDeviceConnection, usbEndpoint);
        byte b1 = buffer.get();
        byte b2 = buffer.get();
        byte b3 = buffer.get();
        byte b4 = buffer.get();
        byte b5 = buffer.get();
        byte b6 = buffer.get();
        byte b7 = buffer.get();
        byte b8 = buffer.get();
        byte[] bytes1 = new byte[8];
        buffer.get(bytes1);
        byte[] bytes2 = new byte[16];
        buffer.get(bytes2);
        byte[] bytes3 = new byte[4];
        buffer.get(bytes3);
        Log.d("USBINFO","CommandQuery bytes1:"+USBBytesUtil.toString(bytes1)+" bytes2:"+USBBytesUtil.toString(bytes2)+" bytes3:"+USBBytesUtil.toString(bytes3));
        buffer.clear();
        return buffer;
    }
}
